package com.edu.service.impl;

import com.edu.bean.User;
import com.edu.mapper.UserMapper;
import com.edu.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;
    @Override

    public int userRegister(User user) {
       if(userMapper.selectUserByUsername(user.getUsername()) != null){
           return -1;
       }else{
           return userMapper.insertUser(user);
       }
    }

    @Override
    public int userLogin(User user) {
       if(userMapper.selectUserByUsername(user.getUsername()) ==  null){
           return -1;
       }else{
           if(userMapper.selectUserByUsernameAndPassword(user) !=null){
               return 1;
           }else{
               return 0;
           }
       }
    }
}
